package collection;

/**
 * 测试泛型
 */
public class Fanxing {
    public static void main(String[] args) {
        //这个容器必须是String类型的值,传入其他值报错
        MyCollection<String> mc = new MyCollection<String>();
        mc.set("ss",0);
        System.out.println(mc.get(0));
        mc.get(0);
    }
}
//简单的泛型容器,<E>必须指定类型
class MyCollection<E>{
    Object[] objs = new Object[5];

    public void set(E e,int index){
        objs[index]=e;
    }
    public E get(int index){
        return (E)objs[index];
    }
}